from common.setting import ensure_path_sep
from utils.mysqlUtils.db_pool import Database

zhcxkj_center_attribute_db = Database(ensure_path_sep("\\config\\shopeev2_config.yaml.bak"),
                                                          "zhcxkj_center_category_attribute_prod")





class Rb_allegro_attribute:


    @staticmethod
    def is_require_ean(category_id_list):
        category_id_ean = []
        get_data_list_sql = """
                SELECT category_id
        FROM zhcxkj_center_attribute.rb_allegro_attribute 
        WHERE 
        category_id in %s
        AND attribute_id= '225693'
        AND required=1
                """
        data_list = zhcxkj_center_attribute_db.fetch_all_tuple(get_data_list_sql,
                                                                           (set(category_id_list),))
        if len(data_list):
            category_id_ean = list(map(lambda x:x[0], data_list))

        return category_id_ean

    @staticmethod
    def get_ean_category_id_list():

        get_data_list_sql = """
                SELECT category_id
        FROM zhcxkj_center_attribute.rb_allegro_attribute 
        WHERE attribute_id= '225693'
        AND required=1
                """
        data_list = zhcxkj_center_attribute_db.fetch_all_tuple(get_data_list_sql,())

        ean_category_id_list = list(map(lambda x:x[0], data_list))
        return ean_category_id_list


if __name__ == '__main__':
    Rb_allegro_attribute.get_ean_category_id_list()